<template>
    <div>
        <div>
            <Form ref="formData" :model="formData" :label-width="80">
                <Row style="margin-top: 10px;">
                    <Col span="8">
                        <FormItem label="姓名" prop="name">
                            <Input v-model="formData.name" placeholder="姓名">
                            </Input>
                        </FormItem>
                    </Col>
                    <Col span="8">
                        <FormItem label="类型" prop="type">
                            <Select v-model="formData.type" clearable
                                    placeholder="请选择">
                                <Option value="成⼈">成⼈</Option>
                                <Option value="学⽣">学⽣</Option>
                            </Select>
                        </FormItem>
                    </Col>
                    <Col span="8">
                        <Divider type="vertical"/>
                        <Button type="primary" @click="add">添加</Button>
                        <Button type="primary" @click="removeBatch"
                                style="margin-left: 8px">删除
                        </Button>
                        <Button type="primary" @click="query" style="marginleft: 8px">查询</Button>
                    </Col>
                </Row>
            </Form>
        </div>
        <div>
            <Table stripe ref="selection" :columns="columns" :data="rows">
            </Table>
        </div>
        <div class="paging">
            <Page :total="total" :page-size="pageSize" show-sizer showelevator show-total
                  @on-change="changePage" @on-page-sizechange="changePageSize"></Page>
        </div>
    </div>
</template>

<script>
    import {baseList} from '@/libs/crud/base-list'

    export default {
        name: "list",
        mixinx: [baseList],
        data() {
            return {
                formData: {name: '', type: ''}
                , columns: [{type: 'selection', width: 60, align: 'center'},
                    {title: '姓名', key: 'name'}, {title: '电话', key: 'phone'},
                    {title: '类型', key: 'type'},
                    {title: '身份证号', key: 'idNumber'},
                    {
                        title: '操作',
                        key: 'action',
                        width: 150,
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('Button', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {marginRight: '5px'}, on: {
                                        click: () => {
                                            this.edit(params.row.id)
                                        }
                                    }
                                }, '修改'),
                                h('Button', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    on: {
                                        click: () => {
                                            this.remove(params.row.id, params.index)
                                        }
                                    }
                                }, '删除')
                            ])
                        }
                    }
                ]
            }
        }
    }
</script>

<style scoped>
    .paging {
        float: right;
        margin-top: 10px;
    }
</style>